package com.kws.merchant.mapper;

import com.kws.merchant.domain.OperationMaintain;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kws.merchant.domain.OperationPolling;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 运维-报修，抢修管理(OperationMaintain)表数据库访问层
 *
 * @author yxy
 * @since 2024-10-28 14:36:38
 */

public interface OperationMaintainMapper extends BaseMapper<OperationMaintain> {


    @Select("select count(*) from tb_operation_maintain o left join tb_device i on o.device_id=i.id where 1=1 ${sql};")
    int countToTal(@Param("sql") String sql);

    @Select("select o.*,i.name as device_name,u.nick_name as handlerName,u1.nick_name as presenterName from tb_operation_maintain o left join tb_device i on o.device_id=i.id left join sys_user u on o.`handler`=u.user_id left join sys_user u1 on o.presenter=u1.user_id where 1=1 ${sql} limit ${sizeNum},${totalPage}; ")
    List<OperationMaintain> getRecords(@Param("sql") String sql, @Param("sizeNum") int sizeNum, @Param("totalPage") Integer totalPage);

    @Select("select count(*) from tb_operation_maintain where merchant_id=${companyId} and type=${type} ${sql};")
    Double countWorkTypeBySql(@Param("companyId") Long companyId,@Param("type")int type,@Param("sql") String sql);

    @Select("select o.*,i.name as device_name,u.nick_name as handlerName,u1.nick_name as presenterName from tb_operation_maintain o left join tb_device i on o.device_id=i.id left join sys_user u on o.`handler`=u.user_id left join sys_user u1 on o.presenter=u1.user_id where o.id=${id}")
    OperationMaintain detailById(@Param("id") Long id);
}
